import Vue from 'vue'
import App from './App.vue'
import router from './router/router'
import store from './store/index'
import './mock/mock.js'
import axios from 'axios'
/* element-ui 组件 */
import {
  Button,
  Radio,
  Container,
  Main,
  Header,
  Aside,
  Menu,
  Submenu,
  MenuItem,
  MenuItemGroup,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Row,
  Col,
  Card,
  Table,
  TableColumn,
  Breadcrumb,
  BreadcrumbItem,
  Tag,
  Form,
  FormItem,
  Input,
  Select,
  Option,
  Switch,
  DatePicker,
  Dialog,
  Pagination,
  MessageBox,
  Message,
  Checkbox,
  Avatar,
  Icon,
  Cascader,
  Upload,
  Steps,
  Step,
  Alert,
  Tree,
  Calendar,
  Popover,
} from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/less/index.less'
import TreeTable from 'vue-table-with-tree-grid'

Vue.config.productionTip = false
Vue.use(Button)
Vue.use(Radio)

Vue.use(Container)
Vue.use(Main)
Vue.use(Header)
Vue.use(Aside)
Vue.use(Menu)
Vue.use(Submenu)
Vue.use(MenuItem)
Vue.use(MenuItemGroup)
Vue.use(Dropdown)
Vue.use(DropdownMenu)
Vue.use(DropdownItem)
Vue.use(Row)
Vue.use(Col)
Vue.use(Card)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Breadcrumb)
Vue.use(BreadcrumbItem)
Vue.use(Tag)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Input)
Vue.use(Select)
Vue.use(Option)
Vue.use(Switch)
Vue.use(DatePicker)
Vue.use(Dialog)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Pagination)
Vue.use(Checkbox)
Vue.use(Icon)
Vue.use(Avatar)
Vue.use(Cascader)
Vue.use(Upload)
Vue.use(Steps)
Vue.use(Step)
Vue.use(Alert)
Vue.use(Tree)
Vue.use(Calendar)
Vue.use(Popover)
Vue.prototype.$http = axios
Vue.prototype.$message = Message
Vue.prototype.$confirm = MessageBox
Vue.component('tree-table', TreeTable)

new Vue({
  router,
  store,
  created() {
    store.commit('addMenu', router)
    const menuList = store.state.menu.menu
    recursionGet(menuList, this.$route.path)
    function recursionGet(list, path) {
      list.some((item) => {
        if (item.path === path) {
          store.commit('selectTab', item)
          return true
        }
        if (item.children instanceof Array && item.children.length > 0) {
          let text = recursionGet(item.children, path)
          if (text) return true
        }
      })
    }
  },
  render: (h) => h(App),
}).$mount('#app')
